package com.dayuanit.dy16.ebook.ebookweb.util;

import java.math.BigDecimal;

public class MoneyUtils {
    public static int yuan2Fen(String amount) {
        BigDecimal bigDecimal = new BigDecimal(amount);
        BigDecimal bigDecimalOther = new BigDecimal("100");
        return bigDecimal.multiply(bigDecimalOther).intValue();
    }

    public static String fen2Yuan(Integer amount) {
        BigDecimal bigDecimal = new BigDecimal(amount);
        BigDecimal bigDecimalOther = new BigDecimal("100");
        return bigDecimal.divide(bigDecimalOther).setScale(2, BigDecimal.ROUND_HALF_DOWN).toString();
    }
}
